import 'package:flutter/material.dart';

import '../../config/public_color.dart';

/// FileName text_subscript
///
/// @Author lax
/// @Date 2024/6/17
///
/// @Description 角标

class TextSubscript extends StatelessWidget {
  static Color? defaultColor;

  final String? text;

  final TextStyle? style;

  final EdgeInsets? margin;
  final EdgeInsets? padding;

  final double? width;
  final double? height;

  final Alignment? alignment;

  late final Color? color;

  TextSubscript({
    super.key,
    this.text,
    this.style = const TextStyle(color: Colors.white, fontSize: 9),
    this.margin,
    this.padding,
    this.width,
    this.height,
    this.alignment = Alignment.center,
    Color? color,
  }) {
    this.color = color ?? defaultColor ?? PublicColor.primary;
  }

  @override
  Widget build(BuildContext context) {
    return Visibility(
      visible: text != null && text != '',
      child: Container(
        margin: margin,
        padding: padding,
        width: width,
        height: height,
        alignment: alignment,
        decoration: BoxDecoration(
          color: color,
          borderRadius: BorderRadius.circular(100.0),
        ),
        child: Text(
          text ?? '',
          textAlign: TextAlign.center,
          style: style,
        ),
      ),
    );
  }
}
